package com.consumerService;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
//import com.netflix.loadbalancer.RoundRobinRule;
//import com.netflix.loadbalancer.AvailabilityFilteringRule;
//import com.netflix.loadbalancer.RetryRule;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
@EnableFeignClients
public class ConsumerServiceApplication {

	public static void main(String[] args) {
		SpringApplication.run(ConsumerServiceApplication.class, args);
	}

	/**
	 * 全局配置负载均衡策略
	 * RoundRobinRule 轮询策略
	 * RandomRule 随机策略
	 * AvailabilityFilteringRule 会先过滤掉，跳闸，访问故障的服务~，对剩下的进行轮询
	 * RetryRule 会先按照轮询获取服务，如果服务获取失败，则会在指定的时间内进行，重试
	 * @return IRule
	 */
	@Bean
	public IRule myRule() {
		return new RandomRule();
//		return new RoundRobinRule();
//		return new AvailabilityFilteringRule();
//		return new RetryRule();
	}
}
